{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<div class="page-header">
	<h1>	
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>
	</h1>
</div>
<form action="" enctype="multipart/form-data" method="post" id="uploadForm" style="margin-bottom: 10px;">
	<input type="file"  style="display: none;" name="excel" id="file_excel" value="" onchange="select_file_excel()"/>
	<a class="btn btn-primary" onclick="file_excel()"><i class="fa fa-fax"></i>导入数据</a>
</form>
<form action="{:url('DealRecord/history')}" method="get">
	<table class="table table-striped table-bordered table-hover">
		<thead>
			<tr>
				<th>
					<input name="trade_acc" type="text" placeholder="输入对手方账号" value="{:input('param.trade_acc')}" />
					&nbsp;
					<input name="attribute" type="text" placeholder="输入交易属性" value="{:input('param.attribute')}" />
					&nbsp;
					<select name="variety_id" id="variety_id">
						<option value="0">请选择商品名称</option>
						{volist name="var" id="var"}
						<option value="{$var.variety_id}" {if condition="$var.variety_id eq input('param.variety_id')"} selected {/if}>{$var.name}</option>
						{/volist}
					</select>

					成交日期&nbsp;<input name="deal_date" type="date" placeholder="输入时间" value="{:input('param.deal_date')}" />

					&nbsp;&nbsp;
					<button class="btn btn-primary">查询</button>&nbsp;&nbsp;&nbsp;
					<a href="{:url('DealRecord/history')}" class="btn btn-primary">清空查询条件</a>
				</th>
			</tr>
		</thead>
	</table>
</form>

<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<span>人数：{$id_num}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<p></p>
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>											
						<th>id</th>
						<th>订单号</th>
						<th>成交编号</th>
						<th>成交日期</th>
						<th>成交时间</th>
						<th>商品代码</th>
						<th>商品名称</th>
						<th>成交价格</th>
						<th>成交数量</th>
						<th>成交金额</th>
						<th>对手方账号</th>
						<th>对手方姓名</th>
						<th>交易属性</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{volist name="list" id="v"}
					<tr>
						<td>{$v.id}</td>
						<td>{$v.order_id}</td>
						<td>{$v.deal_id}</td>
						<td>{$v.deal_date}</td>
						<td>{$v.deal_time}</td>
						<td>{$v.variety_id}</td>
						<td>{$v.variety_name}</td>
						<td>{$v.deal_price}</td>
						<td>{$v.deal_num}</td>
						<td>{$v.deal_money}</td>
						<td>{$v.trade_acc}</td>
						<td>{$v.name}</td>
						<td>{$v.attribute}</td>
						<td>
							<a class="delete btn btn-xs btn-danger" href="del/id/{$v.id}">
								<i class="fa fa-trash bigger-120"></i>
							</a>
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
		</div>
		{$page}
	</div>
</div>
{/block}
{block name="javascript"}
<script>
	//导入excel
	function file_excel(){
		$("#file_excel").click();
	}
	//选择文件
	function select_file_excel() {

		$.ajax({
			url: "{:url('DealRecord/do_upload')}",
			type: 'POST',
			cache: false,
			data: new FormData($('#uploadForm')[0]),
			dataType:'json',
			processData: false,
			contentType: false,
			success:function(json){
				//todo 待处理代码
				if(json.code == 1){
					alert(json.info);
					window.location.href = "/admin/DealRecord/history";
				}else{
					alert(json.info);
				}
			}
		});
	}
</script>
<script>	
$(function(){
   $("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	

      $("#search1").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        //alert(url);
        window.location.href = url;
    });	
});
</script>
{/block}